Código fuente de 'Ordena array 3.asp'

<html>

<head>
<title>Ordena array 3 - Códigos asp, programacion asp, descargas asp, rutinas asp</title>
</head>

<p align="center"><b><font size="3">Ordena array 3</font></b>
<body style="font-family: Arial; font-size: 11pt"></p>

<%
FUNCTION OrdenaVector(varArray)
	For i = UBound(varArray) - 1  To 1 Step - 1
		MaxVal = varArray(i)
		MaxIndex = i
	
		For j = 0 To i
			If varArray(j) > MaxVal Then
				MaxVal = varArray(j)
				MaxIndex = j
			End If
		Next
	
		If MaxIndex < i Then
			varArray(MaxIndex) = varArray(i)
			varArray(i) = MaxVal
		End If
	Next 
END FUNCTION


REDIM Vector(8)

Vector(0)="Elvis"
Vector(1)="Helicopter"
Vector(2)="Corn"
Vector(3)="Apple"
Vector(4)="Drum"
Vector(5)="Green"
Vector(6)="Flowers"
Vector(7)="Big"

Response.write "<TABLE BORDER=1 WIDTH=100% ><TR><TD><B>Original</B></TD><TD><B>Ordenado</B></TD></TR>"
Response.write "<TR><TD>"

FOR i = 0 TO UBOUND(Vector) - 1
	Response.write "<B>Vector(" & i & ") valor: </B>" & Vector(i) & "<BR>"
NEXT

Response.write "</TD><TD>"

OrdenaVector Vector

FOR i = 0 TO UBOUND(Vector) - 1
	Response.write "<B>Vector(" & i & ") valor: </B>" & Vector(i) & "<BR>"
NEXT


Response.write "</TD></TR></TABLE>"
%>

</body>
</html>